package com.hinnotek.amoeba.repo

import com.hinnotek.amoeba.api.ApiService
import com.hinnotek.amoeba.base.BaseBean
import com.hinnotek.amoeba.bean.old.CompanyContractByIdBean
import com.hinnotek.amoeba.bean.old.CompanyContractListBean
import com.hinnotek.amoeba.bean.old.PBDetailBean
import com.hinnotek.amoeba.bean.old.PBListBean
import com.lee.common.base.BaseRepository
import com.lee.common.network.net.StateLiveData
import okhttp3.RequestBody
import javax.inject.Inject

class ContractRepo @Inject constructor(private val service: ApiService) : BaseRepository() {

    /**
     * app端获取合同列表分页接口
     */
    suspend fun getCompanyContractById(
        companyContractId: Int,
        stateLiveData: StateLiveData<CompanyContractByIdBean>
    ) {
        executeResp({ service.getCompanyContractById(companyContractId) }, stateLiveData)
    }

    /**
     * app端获取合同列表分页接口
     */
    suspend fun getCompanyContractPageByUnComplete(
        pageNo: Int,
        pageSize: Int,
        stateLiveData: StateLiveData<MutableList<PBListBean>>
    ) {
        executeResp({ service.getCompanyContractPageByUnComplete(pageNo, pageSize) }, stateLiveData)
    }

    suspend fun getCompanyContractPage(
        requestBody: RequestBody,
        stateLiveData: StateLiveData<MutableList<CompanyContractListBean>>
    ) {
        executeResp({ service.getCompanyContractPage(requestBody) }, stateLiveData)
    }

    suspend fun addCompanyContract(
        requestBody: RequestBody,
        stateLiveData: StateLiveData<BaseBean>
    ) {
        executeResp({ service.addCompanyContract(requestBody) }, stateLiveData)
    }

    suspend fun getCompanyContractByIdForUnComplete(companyContractId: Int, stateLiveData: StateLiveData<PBDetailBean>) {
        executeResp({ service.getCompanyContractByIdForUnComplete(companyContractId) }, stateLiveData)
    }

    suspend fun addCompanyContractBack(companyContractId: Int, backMoney: String, stateLiveData: StateLiveData<BaseBean>) {
        executeResp({ service.addCompanyContractBack(companyContractId,backMoney) }, stateLiveData)
    }

    suspend fun updateCompanyContractBackStateComplete(companyContractId: Int, stateLiveData: StateLiveData<BaseBean>) {
        executeResp({ service.updateCompanyContractBackStateComplete(companyContractId) }, stateLiveData)
    }

}